package org.garbagecan.quartzstudy.stateful;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.garbagecan.quartzstudy.TestUtil;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;

@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class MyStatefulJob implements Job {
	
	private Log log = LogFactory.getLog(MyStatefulJob.class);
	
	public void execute(JobExecutionContext context)
			throws JobExecutionException {
		log.info("Time  : " + TestUtil.getDateTime());
		
		JobDataMap jdm = context.getJobDetail().getJobDataMap();
		log.info(jdm.get("mykey1"));
		log.info(jdm.get("mykey2"));

		try {
			Thread.sleep(8 * 1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
